require 'json'
require 'spoule/accessor'
require 'spoule/enums'
require 'spoule/json'

# (value): {
#         "id": (value),
#         "type": (value),
#         "$ref": (value),
#         "description": (value),
#         "default": (value),
#         "required": (value),
#         "format": (value),
#         "pattern": (value),
#         "minimum": (value),
#         "maximum": (value),
#         "enum": [
#           (value)
#         ],
#         "enumDescriptions": [
#           (value)
#         ],
#         "repeated": (value),
#         "location": (value),
#         "properties": {
          
#             (value): (object)
          
#         },
#         "additionalProperties": (object),
#         "items": (object)
#       }

module Spoule
  class Schema
    def initialize
      @properties = []
    end
    
    def <<(o)
      case o
      when Spoule::Property::Base
        @properties << o
      else
        raise "Cannot accept objects of type #{o.class}!"
      end
    end

    def to_json(*opts)
      @properties.inject([]) {|a,x| a << x.to_json(opts) }.join(',')
    end
  end
end # module Spoule
